﻿using MetroDataApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web.Http;

namespace MetroDataApi.Controllers
{
    public class ReviewRecentChangesController : ApiController
    {
        public HttpResponseMessage Get(int prjId, string monitorType, string location, DateTime date)
        {

            var change = Recent2Changes.GetReviewedRecentChanges(prjId, location, monitorType, date);

            this.Configuration.Formatters.Clear();
            this.Configuration.Formatters.Add(new JsonMediaTypeFormatter());
            this.Configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings()
                {
                    Formatting = Newtonsoft.Json.Formatting.Indented,
                    Converters = new List<JsonConverter> { new StandardFloatConverter() }
                };
            
            return Request.CreateResponse(HttpStatusCode.OK, change, "application/json");
        }
    }
}
